void recursion(int array[], int reg[],int start, int end){
    if(start>=end){
        return;
    }
    int len=end-start,mid=(len>>1)+start;
    int start1=start,end1=mid;
    int start2=mid+1,end2=end;
    recursion(array,reg,start1,end1);
    recursion(array,reg,start2,end2);
    int k=start;
    while(start1<=end1 && start2<=end2){
        reg[k++]=array[start1]<array[start2]?array[start1++]:array[start2++];
    }
    while(start1<=end1){
        reg[k++]=array[start1++];
    }
    while(start2<=end2){
        reg[k++]=array[start2++];
    }
    for(k=start;k<=end;k++){
        array[k]=reg[k];
    }
}

void merge_sort(int array[],const int len){
    int reg[len];
    recursion(array,reg,0,len-1);
}
